<script setup lang="ts">
const state = reactive({
  navList: [
    {
      title: '产品中心',
      link: '/product',
      value: 'product'
    },
    {
      title: '解决方案',
      link: '/solution',
      value: 'solution'
    },
    {
      title: '合作伙伴',
      link: '/partner',
      value: 'partner'
    },
    {
      title: '客户案例',
      link: '/cases',
      value: 'cases',
    },
    {
      title: '关于华途',
      link: '/about',
      value: 'about'
    },
  ],
});
const activeNav = ref()
const setNavActive = (item: { value: any; }) => {
  activeNav.value = item.value
}
const headerMouseLeave = () => {
  activeNav.value = ''
}
</script>

<template>
  <div class="ht-home-header" @mouseleave="headerMouseLeave">
    <div class="ht-home-header-content">
      <div class="ht-home-header-logo">
        <NuxtLink to="/"  target="_blank">
          <img class="home" src="~/assets/logo_home.png" alt=""/>
          <img class="normal" src="~/assets/logo.png" alt=""/>
        </NuxtLink>
      </div>
      <nav class="ht-home-header-nav">
        <div class="ht-home-header-nav-item" v-for="(item, index) in state.navList"
             :key="index"
             @mouseover.stop="setNavActive(item)"
        >
          <NuxtLink :to="item.link"  target="_blank">{{ item.title }}</NuxtLink>
        </div>
      </nav>
      <div class="ht-home-header-langs">
        <div class="home">
          <LangHome/>

        </div>
        <div class="normal">
          <Lang/>
        </div>
      </div>
      <div class="ht-home-header-tel">
        <HeadersHeaderTel/>
      </div>
    </div>
    <HeadItem :active-nav="activeNav"/>
    <div class="nav-top-content" :class="activeNav==='product'?activeNav:''">
      <HeadItemProduct/>
    </div>
  </div>
</template>

<style scoped lang="scss">
.ht-home-header {
  width: 100%;
  position: absolute;
  top: 0;
  z-index: 1;
  box-shadow: 0 0.04rem 0.29rem 0.01rem rgba(0, 0, 0, 0.06);

  &:hover {
    background: #fff;

    .ht-home-header-content {
      .ht-home-header-logo {
        img {
          &.home {
            display: none;
          }

          &.normal {
            display: block;
          }
        }
      }

      .ht-home-header-nav {
        .ht-home-header-nav-item {
          a {
            color: #111;
          }
        }

      }

      .ht-home-header-langs {
        .normal {
          display: block;
        }

        .home {
          display: none;
        }
      }
    }
  }

  .ht-home-header-content {
    display: flex;
    align-items: center;
    width: 100%;
    height: 1.33rem;
    // background: #ccc;

    .ht-home-header-logo {
      margin-left: 0.81rem;

      img {
        width: 2.587rem;
        height: 0.8875rem;
          &.home {
            display: block;
          }

          &.normal {
            display: none;
          }
      }
    }

    .ht-home-header-nav {
      display: flex;
      height: 100%;
      margin-left: 4.8rem;

      .ht-home-header-nav-item {
        margin-right: 0.25rem;
        margin-left: 0.4rem;
        position: relative;

        &:first-child {
          margin-left: 0;
        }

        a {
          color: #fff;
          font-size: 0.25rem;
          height: 100%;
          display: flex;
          align-items: center;
        }

        &:hover {
          a {
            color: #3ab5ec;
          }
        }
      }
    }

    .ht-home-header-langs {
      margin-left: 3.13rem;

      .normal {
        display: none;
      }

      .home {
        display: block;
      }
    }

    .ht-home-header-tel {
      margin-left: 0.57rem;
    }
  }
}

.nav-top-content {
  display: none;

  &.product {
    display: block;
  }
}
</style>
